package com.qf.cloud2203.getcoupons.coupons.controller;

import cn.hutool.jwt.JWT;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.qf.cloud2203.domain.constants.Constants;
import com.qf.cloud2203.domain.entity.Coupon;
import com.qf.cloud2203.domain.vo.ResultVo;
import com.qf.cloud2203.getcoupons.coupons.service.impl.UsersServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.nio.charset.StandardCharsets;
import java.util.Date;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ada
 * @since 2023-03-10
 */
@RestController
@RequestMapping("/users")
public class UsersController {
    @Autowired
    UsersServiceImpl usersServiceImpl;

    @PostMapping("/getCoupon")
    public ResultVo getCoupon() throws JsonProcessingException {
        Coupon coupon = usersServiceImpl.getCoupon();
        ResultVo ok = ResultVo.ok(coupon);
        ok.put("msg", "抢卷成功");
        return ok;
    }

    @GetMapping("/gradCoupon")
    public ResultVo gradCoupon(String name, String phone) throws Exception {
        ResultVo resultVo = usersServiceImpl.gradCoupon(name, phone);
        return resultVo;
    }
}
